$(function () {
    $("#cPlanTimePicker").datetimepicker({language :'zh-CN',});
});

/**选择模板**/
function loadChooseMoadl() {
    $.post(ctx+"SaleHelp/getScalePlanModal",{},function (r) {
        $("#sale_select_user").empty().append(r).modal('show').draggable();
    });
}

/**保存计划的信息**/
function saveAddPlanAllInfo() {
    //<input id="cPlanCusid" name="cPlanCusid" type="hidden" value="">
    var cPlanTime = $("#cPlanTime").val();
    if(cPlanTime == ""){$JuXue.n_danger("执行时间不能为空");return}

    /**获取标题**/
    var cPlanTitle = $("#cPlanTitle").val();
    if (cPlanTitle == ""){$JuXue.n_danger("标题不能为空");return}
    //获取时间

    //获取内容
    var cPlanDesc = $("#cPlanDesc").val();
    if (cPlanDesc == ""){$JuXue.n_danger("执行内容不能为空");return}

    var userIds = new Array();
    var userName = new Array();
    //人员类型
    var typesArray = new Array();

    /**获取客户的信息**/
    $("#zhanshiButton").find("button").each(function () {
        var uuid = $(this).attr("uuid");
        userIds.push(uuid);
        var name = $(this).text();
        userName.push(name);
        //人员类型
        var types = $(this).attr("types");
        typesArray.push(types);
    });
    $("#xialazhanshi").find("button").each(function () {
        var uuid = $(this).attr("uuid");
        userIds.push(uuid);
        var name = $(this).text();
        userName.push(name);
        //人员类型
        var types = $(this).attr("types");
        typesArray.push(types);
    });
    if (userIds.length <= 0){$JuXue.n_danger("执行的客户不能为空");return}

    if (userIds.length !=typesArray.length ){$JuXue.n_danger("获取有效数据失败");return}
    var cPlanCusid = userIds.join(",");
    var cPlanCname = userName.join(",");
    //类型凭借
    var typesAll =  typesArray.join(",");
    //获取类型
    var sale= $("#saleplanTypehide").val();
    $("#myCustomer-modal").empty().modal("hide");
    $.post(ctx+"SaleHelp/saveScalePlan",{cPlanType:sale,cPlanTitle:cPlanTitle,cPlanCname:cPlanCname,
        cPlanTime:cPlanTime,cPlanDesc:cPlanDesc,cPlanCusid:cPlanCusid,typesAll:typesAll},function (r) {
        if (r.code == 0){
            $JuXue.n_success("创建计划成功");
        }else{
            $JuXue.n_danger(r.msg);
        }
    });

}
